package com.xcity.game.rank.impl;

import java.util.Comparator;

import com.xcity.db.entity.Player;
import com.xcity.db.entity.Ranking;
import com.xcity.game.event.GameEvents;
import com.xcity.game.rank.BaseRankingList;

import naga.x.event.Event;

public class CircleTodayRankingList extends BaseRankingList{

	public CircleTodayRankingList(int type, int capacity, Comparator<Ranking> comparator) {
		super(type, capacity, comparator);
	}

	@Override
	public int[] getEventTypes() {
		return new int[]{
				GameEvents.EVENT_ADD_CIRCLE_SCORE,
		};
	}

	@Override
	public void handleEvent(Event event) {
		switch (event.getType()) {
		case GameEvents.EVENT_ADD_CIRCLE_SCORE:
			handleAddScore(event.getParameter(0), event.getParameter(1));
			break;
		}
	}
	
	public void handleAddScore(Player player, int addVal){
		Ranking rank = findEntry(player.getId());
		if(rank == null){
			setDirty(player, addVal);
		}else{
			setDirty(player, rank.getBufferValue() + addVal);
		}
	}
}
